{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Execute this cell to install dependencies\n",
    "%pip install sf-hamilton[visualization]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Resusing Functions Example [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/dagworks-inc/hamilton/blob/main/examples/reusing_functions/reusing_functions.ipynb) [![GitHub badge](https://img.shields.io/badge/github-view_source-2b3137?logo=github)](https://github.com/apache/hamilton/blob/main/examples/reusing_functions/reusing_functions.ipynb)\n",
    "\n",
    "\n",
    "This notebook demonstrates the use of the subdag operator.\n",
    "\n",
    "The subdag operator allows you to effectively run a driver within a node.\n",
    "In this case, we are calculating unique website visitors from the following set of parameters:\n",
    "\n",
    "1. Region = CA (canada) or US (United States)\n",
    "2. Granularity of data = (day, week, month)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pre-requisites"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "You need to have the following installed and set up:\n",
    "- Hamilton\n",
    "- Pandas\n",
    "\n",
    "Execute the code commented below to install the above if you don't have them already installed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# %pip install sf-hamilton pandas"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Importing all the things you need\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import Any, Dict\n",
    "import pandas as pd\n",
    "from hamilton.base import ResultMixin, SimplePythonGraphAdapter\n",
    "from hamilton import driver\n",
    "%load_ext hamilton.plugins.jupyter_magic"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`unique_users` module"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 12.1.0 (20240811.2233)\n",
       " -->\n",
       "<!-- Pages: 1 -->\n",
       "<svg width=\"552pt\" height=\"223pt\"\n",
       " viewBox=\"0.00 0.00 551.55 222.80\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 218.8)\">\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-218.8 547.55,-218.8 547.55,4 -4,4\"/>\n",
       "<g id=\"clust1\" class=\"cluster\">\n",
       "<title>cluster__legend</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" points=\"70.38,-74.8 70.38,-206.8 155.23,-206.8 155.23,-74.8 70.38,-74.8\"/>\n",
       "<text text-anchor=\"middle\" x=\"112.8\" y=\"-189.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Legend</text>\n",
       "</g>\n",
       "<!-- filtered_interactions -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M393.2,-64.6C393.2,-64.6 266.6,-64.6 266.6,-64.6 260.6,-64.6 254.6,-58.6 254.6,-52.6 254.6,-52.6 254.6,-13 254.6,-13 254.6,-7 260.6,-1 266.6,-1 266.6,-1 393.2,-1 393.2,-1 399.2,-1 405.2,-7 405.2,-13 405.2,-13 405.2,-52.6 405.2,-52.6 405.2,-58.6 399.2,-64.6 393.2,-64.6\"/>\n",
       "<text text-anchor=\"start\" x=\"265.4\" y=\"-41.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"295.78\" y=\"-13.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- unique_users -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M531.55,-100.6C531.55,-100.6 446.2,-100.6 446.2,-100.6 440.2,-100.6 434.2,-94.6 434.2,-88.6 434.2,-88.6 434.2,-49 434.2,-49 434.2,-43 440.2,-37 446.2,-37 446.2,-37 531.55,-37 531.55,-37 537.55,-37 543.55,-43 543.55,-49 543.55,-49 543.55,-88.6 543.55,-88.6 543.55,-94.6 537.55,-100.6 531.55,-100.6\"/>\n",
       "<text text-anchor=\"start\" x=\"445\" y=\"-77.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"469.75\" y=\"-49.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- filtered_interactions&#45;&gt;unique_users -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>filtered_interactions&#45;&gt;unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M405.25,-49.85C411.14,-51.2 417.06,-52.56 422.88,-53.9\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"421.91,-57.26 432.44,-56.09 423.48,-50.44 421.91,-57.26\"/>\n",
       "</g>\n",
       "<!-- _filtered_interactions_inputs -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>_filtered_interactions_inputs</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"225.6,-65.6 0,-65.6 0,0 225.6,0 225.6,-65.6\"/>\n",
       "<text text-anchor=\"start\" x=\"57.05\" y=\"-37.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">region</text>\n",
       "<text text-anchor=\"start\" x=\"169.3\" y=\"-37.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">str</text>\n",
       "<text text-anchor=\"start\" x=\"14.68\" y=\"-16.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">website_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"142.68\" y=\"-16.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- _filtered_interactions_inputs&#45;&gt;filtered_interactions -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>_filtered_interactions_inputs&#45;&gt;filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M226.07,-32.8C231.76,-32.8 237.43,-32.8 243.01,-32.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"242.83,-36.3 252.83,-32.8 242.83,-29.3 242.83,-36.3\"/>\n",
       "</g>\n",
       "<!-- _unique_users_inputs -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>_unique_users_inputs</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"370.2,-127.47 289.6,-127.47 289.6,-82.12 370.2,-82.12 370.2,-127.47\"/>\n",
       "<text text-anchor=\"start\" x=\"304.4\" y=\"-99.38\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">grain</text>\n",
       "<text text-anchor=\"start\" x=\"340.4\" y=\"-99.38\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- _unique_users_inputs&#45;&gt;unique_users -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>_unique_users_inputs&#45;&gt;unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M370.51,-95.72C386.31,-92.09 404.91,-87.83 422.6,-83.77\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"423.31,-87.2 432.27,-81.55 421.75,-80.38 423.31,-87.2\"/>\n",
       "</g>\n",
       "<!-- input -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>input</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"139.8,-120.47 85.8,-120.47 85.8,-83.12 139.8,-83.12 139.8,-120.47\"/>\n",
       "<text text-anchor=\"middle\" x=\"112.8\" y=\"-96.38\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input</text>\n",
       "</g>\n",
       "<!-- function -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>function</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M135.23,-175.48C135.23,-175.48 90.38,-175.48 90.38,-175.48 84.38,-175.48 78.38,-169.48 78.38,-163.48 78.38,-163.48 78.38,-150.12 78.38,-150.12 78.38,-144.12 84.38,-138.12 90.38,-138.12 90.38,-138.12 135.23,-138.12 135.23,-138.12 141.23,-138.12 147.23,-144.12 147.23,-150.12 147.23,-150.12 147.23,-163.48 147.23,-163.48 147.23,-169.48 141.23,-175.48 135.23,-175.48\"/>\n",
       "<text text-anchor=\"middle\" x=\"112.8\" y=\"-151.38\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">function</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x19f4cb0d0d0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%cell_to_module unique_users --display\n",
    "\n",
    "import pandas as pd\n",
    "\n",
    "_grain_mapping = {\"day\": \"D\", \"week\": \"W\", \"month\": \"M\"}\n",
    "\n",
    "\n",
    "def _validate_grain(grain: str):\n",
    "    assert grain in [\"day\", \"week\", \"month\"]\n",
    "\n",
    "\n",
    "def filtered_interactions(website_interactions: pd.DataFrame, region: str) -> pd.DataFrame:\n",
    "    return website_interactions[website_interactions.region == region]\n",
    "\n",
    "\n",
    "def unique_users(filtered_interactions: pd.DataFrame, grain: str) -> pd.Series:\n",
    "    \"\"\"Gives the number of shares traded by the frequency\"\"\"\n",
    "    _validate_grain(grain)\n",
    "    return filtered_interactions.resample(_grain_mapping[grain])[\"user_id\"].nunique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`reusable_subdags` module"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 12.1.0 (20240811.2233)\n",
       " -->\n",
       "<!-- Pages: 1 -->\n",
       "<svg width=\"1153pt\" height=\"986pt\"\n",
       " viewBox=\"0.00 0.00 1152.65 985.80\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 981.8)\">\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-981.8 1148.65,-981.8 1148.65,4 -4,4\"/>\n",
       "<g id=\"clust1\" class=\"cluster\">\n",
       "<title>cluster__legend</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" points=\"78.62,-892.8 78.62,-969.8 163.48,-969.8 163.48,-892.8 78.62,-892.8\"/>\n",
       "<text text-anchor=\"middle\" x=\"121.05\" y=\"-952.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Legend</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>weekly_unique_users_US</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M1128.15,-924.6C1128.15,-924.6 964.05,-924.6 964.05,-924.6 958.05,-924.6 952.05,-918.6 952.05,-912.6 952.05,-912.6 952.05,-873 952.05,-873 952.05,-867 958.05,-861 964.05,-861 964.05,-861 1128.15,-861 1128.15,-861 1134.15,-861 1140.15,-867 1140.15,-873 1140.15,-873 1140.15,-912.6 1140.15,-912.6 1140.15,-918.6 1134.15,-924.6 1128.15,-924.6\"/>\n",
       "<text text-anchor=\"start\" x=\"962.85\" y=\"-901.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_US</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-873.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.grain -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>monthly_unique_users_CA.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M540.95,-309.6C540.95,-309.6 331.1,-309.6 331.1,-309.6 325.1,-309.6 319.1,-303.6 319.1,-297.6 319.1,-297.6 319.1,-258 319.1,-258 319.1,-252 325.1,-246 331.1,-246 331.1,-246 540.95,-246 540.95,-246 546.95,-246 552.95,-252 552.95,-258 552.95,-258 552.95,-297.6 552.95,-297.6 552.95,-303.6 546.95,-309.6 540.95,-309.6\"/>\n",
       "<text text-anchor=\"start\" x=\"329.9\" y=\"-286.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_CA.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-258.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.unique_users -->\n",
       "<g id=\"node11\" class=\"node\">\n",
       "<title>monthly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M906.55,-247.6C906.55,-247.6 641.95,-247.6 641.95,-247.6 635.95,-247.6 629.95,-241.6 629.95,-235.6 629.95,-235.6 629.95,-196 629.95,-196 629.95,-190 635.95,-184 641.95,-184 641.95,-184 906.55,-184 906.55,-184 912.55,-184 918.55,-190 918.55,-196 918.55,-196 918.55,-235.6 918.55,-235.6 918.55,-241.6 912.55,-247.6 906.55,-247.6\"/>\n",
       "<text text-anchor=\"start\" x=\"640.75\" y=\"-224.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_CA.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-196.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.grain&#45;&gt;monthly_unique_users_CA.unique_users -->\n",
       "<g id=\"edge12\" class=\"edge\">\n",
       "<title>monthly_unique_users_CA.grain&#45;&gt;monthly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M553.21,-256.38C574.23,-252.5 596.46,-248.4 618.39,-244.36\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"618.78,-247.84 627.98,-242.59 617.51,-240.96 618.78,-247.84\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.unique_users -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>daily_unique_users_US.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M894.92,-124.6C894.92,-124.6 653.58,-124.6 653.58,-124.6 647.58,-124.6 641.58,-118.6 641.58,-112.6 641.58,-112.6 641.58,-73 641.58,-73 641.58,-67 647.58,-61 653.58,-61 653.58,-61 894.92,-61 894.92,-61 900.92,-61 906.92,-67 906.92,-73 906.92,-73 906.92,-112.6 906.92,-112.6 906.92,-118.6 900.92,-124.6 894.92,-124.6\"/>\n",
       "<text text-anchor=\"start\" x=\"652.38\" y=\"-101.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_US.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-73.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_US -->\n",
       "<g id=\"node16\" class=\"node\">\n",
       "<title>daily_unique_users_US</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M1121.03,-124.6C1121.03,-124.6 971.18,-124.6 971.18,-124.6 965.18,-124.6 959.18,-118.6 959.18,-112.6 959.18,-112.6 959.18,-73 959.18,-73 959.18,-67 965.18,-61 971.18,-61 971.18,-61 1121.03,-61 1121.03,-61 1127.03,-61 1133.03,-67 1133.03,-73 1133.03,-73 1133.03,-112.6 1133.03,-112.6 1133.03,-118.6 1127.03,-124.6 1121.03,-124.6\"/>\n",
       "<text text-anchor=\"start\" x=\"969.98\" y=\"-101.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_US</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-73.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.unique_users&#45;&gt;daily_unique_users_US -->\n",
       "<g id=\"edge18\" class=\"edge\">\n",
       "<title>daily_unique_users_US.unique_users&#45;&gt;daily_unique_users_US</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M907.41,-92.8C920.94,-92.8 934.51,-92.8 947.57,-92.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"947.38,-96.3 957.38,-92.8 947.38,-89.3 947.38,-96.3\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.unique_users -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>monthly_unique_users_US.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M906.17,-432.6C906.17,-432.6 642.33,-432.6 642.33,-432.6 636.33,-432.6 630.33,-426.6 630.33,-420.6 630.33,-420.6 630.33,-381 630.33,-381 630.33,-375 636.33,-369 642.33,-369 642.33,-369 906.17,-369 906.17,-369 912.17,-369 918.17,-375 918.17,-381 918.17,-381 918.17,-420.6 918.17,-420.6 918.17,-426.6 912.17,-432.6 906.17,-432.6\"/>\n",
       "<text text-anchor=\"start\" x=\"641.12\" y=\"-409.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_US.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-381.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US -->\n",
       "<g id=\"node22\" class=\"node\">\n",
       "<title>monthly_unique_users_US</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M1132.28,-432.6C1132.28,-432.6 959.93,-432.6 959.93,-432.6 953.93,-432.6 947.93,-426.6 947.93,-420.6 947.93,-420.6 947.93,-381 947.93,-381 947.93,-375 953.93,-369 959.93,-369 959.93,-369 1132.28,-369 1132.28,-369 1138.28,-369 1144.28,-375 1144.28,-381 1144.28,-381 1144.28,-420.6 1144.28,-420.6 1144.28,-426.6 1138.28,-432.6 1132.28,-432.6\"/>\n",
       "<text text-anchor=\"start\" x=\"958.73\" y=\"-409.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_US</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-381.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.unique_users&#45;&gt;monthly_unique_users_US -->\n",
       "<g id=\"edge23\" class=\"edge\">\n",
       "<title>monthly_unique_users_US.unique_users&#45;&gt;monthly_unique_users_US</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M918.47,-400.8C924.47,-400.8 930.44,-400.8 936.35,-400.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"936.09,-404.3 946.09,-400.8 936.09,-397.3 936.09,-404.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>weekly_unique_users_CA</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M1128.53,-596.6C1128.53,-596.6 963.68,-596.6 963.68,-596.6 957.68,-596.6 951.68,-590.6 951.68,-584.6 951.68,-584.6 951.68,-545 951.68,-545 951.68,-539 957.68,-533 963.68,-533 963.68,-533 1128.53,-533 1128.53,-533 1134.53,-533 1140.53,-539 1140.53,-545 1140.53,-545 1140.53,-584.6 1140.53,-584.6 1140.53,-590.6 1134.53,-596.6 1128.53,-596.6\"/>\n",
       "<text text-anchor=\"start\" x=\"962.48\" y=\"-573.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_CA</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-545.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- website_interactions -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>website_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M186.98,-514.6C186.98,-514.6 55.13,-514.6 55.13,-514.6 49.13,-514.6 43.13,-508.6 43.13,-502.6 43.13,-502.6 43.13,-463 43.13,-463 43.13,-457 49.13,-451 55.13,-451 55.13,-451 186.98,-451 186.98,-451 192.98,-451 198.98,-457 198.98,-463 198.98,-463 198.98,-502.6 198.98,-502.6 198.98,-508.6 192.98,-514.6 186.98,-514.6\"/>\n",
       "<text text-anchor=\"start\" x=\"53.93\" y=\"-491.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">website_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"86.93\" y=\"-463.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"node8\" class=\"node\">\n",
       "<title>daily_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M577.7,-801.6C577.7,-801.6 294.35,-801.6 294.35,-801.6 288.35,-801.6 282.35,-795.6 282.35,-789.6 282.35,-789.6 282.35,-750 282.35,-750 282.35,-744 288.35,-738 294.35,-738 294.35,-738 577.7,-738 577.7,-738 583.7,-738 589.7,-744 589.7,-750 589.7,-750 589.7,-789.6 589.7,-789.6 589.7,-795.6 583.7,-801.6 577.7,-801.6\"/>\n",
       "<text text-anchor=\"start\" x=\"293.15\" y=\"-778.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_CA.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-750.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;daily_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;daily_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M199.27,-495.39C215.53,-501.47 231.08,-510.48 242.1,-523.8 300.75,-594.7 209.52,-660.42 271.1,-728.8 271.93,-729.73 272.79,-730.63 273.65,-731.52\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"271.02,-733.86 280.78,-737.99 275.73,-728.68 271.02,-733.86\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"node13\" class=\"node\">\n",
       "<title>weekly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M584.83,-555.6C584.83,-555.6 287.23,-555.6 287.23,-555.6 281.23,-555.6 275.23,-549.6 275.23,-543.6 275.23,-543.6 275.23,-504 275.23,-504 275.23,-498 281.23,-492 287.23,-492 287.23,-492 584.83,-492 584.83,-492 590.83,-492 596.83,-498 596.83,-504 596.83,-504 596.83,-543.6 596.83,-543.6 596.83,-549.6 590.83,-555.6 584.83,-555.6\"/>\n",
       "<text text-anchor=\"start\" x=\"286.03\" y=\"-532.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_CA.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-504.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;weekly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge14\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;weekly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M199.41,-492.93C219.16,-495.52 241.18,-498.41 263.62,-501.35\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"263.15,-504.81 273.52,-502.64 264.06,-497.87 263.15,-504.81\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"node15\" class=\"node\">\n",
       "<title>monthly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M588.58,-473.6C588.58,-473.6 283.48,-473.6 283.48,-473.6 277.48,-473.6 271.48,-467.6 271.48,-461.6 271.48,-461.6 271.48,-422 271.48,-422 271.48,-416 277.48,-410 283.48,-410 283.48,-410 588.58,-410 588.58,-410 594.58,-410 600.58,-416 600.58,-422 600.58,-422 600.58,-461.6 600.58,-461.6 600.58,-467.6 594.58,-473.6 588.58,-473.6\"/>\n",
       "<text text-anchor=\"start\" x=\"282.28\" y=\"-450.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_US.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-422.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;monthly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge16\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;monthly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M199.41,-472.67C217.98,-470.23 238.56,-467.54 259.61,-464.78\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"260.03,-468.25 269.49,-463.48 259.12,-461.31 260.03,-468.25\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"node18\" class=\"node\">\n",
       "<title>monthly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M588.95,-227.6C588.95,-227.6 283.1,-227.6 283.1,-227.6 277.1,-227.6 271.1,-221.6 271.1,-215.6 271.1,-215.6 271.1,-176 271.1,-176 271.1,-170 277.1,-164 283.1,-164 283.1,-164 588.95,-164 588.95,-164 594.95,-164 600.95,-170 600.95,-176 600.95,-176 600.95,-215.6 600.95,-215.6 600.95,-221.6 594.95,-227.6 588.95,-227.6\"/>\n",
       "<text text-anchor=\"start\" x=\"281.9\" y=\"-204.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_CA.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-176.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;monthly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge19\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;monthly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M199.27,-470.21C215.53,-464.13 231.08,-455.12 242.1,-441.8 300.75,-370.9 209.52,-305.18 271.1,-236.8 271.37,-236.5 271.64,-236.21 271.91,-235.92\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"274.31,-238.46 279.12,-229.03 269.47,-233.4 274.31,-238.46\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"node28\" class=\"node\">\n",
       "<title>weekly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M584.45,-883.6C584.45,-883.6 287.6,-883.6 287.6,-883.6 281.6,-883.6 275.6,-877.6 275.6,-871.6 275.6,-871.6 275.6,-832 275.6,-832 275.6,-826 281.6,-820 287.6,-820 287.6,-820 584.45,-820 584.45,-820 590.45,-820 596.45,-826 596.45,-832 596.45,-832 596.45,-871.6 596.45,-871.6 596.45,-877.6 590.45,-883.6 584.45,-883.6\"/>\n",
       "<text text-anchor=\"start\" x=\"286.4\" y=\"-860.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_US.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-832.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;weekly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge25\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;weekly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M199.34,-494.96C215.7,-501.06 231.28,-510.18 242.1,-523.8 321.83,-624.19 187.22,-713.84 271.1,-810.8 271.36,-811.1 271.62,-811.4 271.89,-811.7\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"269.4,-814.16 278.97,-818.7 274.32,-809.18 269.4,-814.16\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.filtered_interactions -->\n",
       "<g id=\"node31\" class=\"node\">\n",
       "<title>daily_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M577.33,-63.6C577.33,-63.6 294.73,-63.6 294.73,-63.6 288.73,-63.6 282.73,-57.6 282.73,-51.6 282.73,-51.6 282.73,-12 282.73,-12 282.73,-6 288.73,0 294.73,0 294.73,0 577.33,0 577.33,0 583.33,0 589.33,-6 589.33,-12 589.33,-12 589.33,-51.6 589.33,-51.6 589.33,-57.6 583.33,-63.6 577.33,-63.6\"/>\n",
       "<text text-anchor=\"start\" x=\"293.53\" y=\"-40.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_US.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;daily_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge29\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;daily_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M199.25,-470.93C215.72,-464.83 231.36,-455.63 242.1,-441.8 292.53,-376.82 217.98,-135.6 271.1,-72.8 272.06,-71.67 273.04,-70.56 274.05,-69.48\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"276.27,-72.2 281.16,-62.8 271.47,-67.11 276.27,-72.2\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.grain -->\n",
       "<g id=\"node7\" class=\"node\">\n",
       "<title>weekly_unique_users_CA.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M536.83,-637.6C536.83,-637.6 335.23,-637.6 335.23,-637.6 329.23,-637.6 323.23,-631.6 323.23,-625.6 323.23,-625.6 323.23,-586 323.23,-586 323.23,-580 329.23,-574 335.23,-574 335.23,-574 536.83,-574 536.83,-574 542.83,-574 548.83,-580 548.83,-586 548.83,-586 548.83,-625.6 548.83,-625.6 548.83,-631.6 542.83,-637.6 536.83,-637.6\"/>\n",
       "<text text-anchor=\"start\" x=\"334.03\" y=\"-614.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_CA.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-586.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.unique_users -->\n",
       "<g id=\"node29\" class=\"node\">\n",
       "<title>weekly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M902.42,-596.6C902.42,-596.6 646.08,-596.6 646.08,-596.6 640.08,-596.6 634.08,-590.6 634.08,-584.6 634.08,-584.6 634.08,-545 634.08,-545 634.08,-539 640.08,-533 646.08,-533 646.08,-533 902.42,-533 902.42,-533 908.42,-533 914.42,-539 914.42,-545 914.42,-545 914.42,-584.6 914.42,-584.6 914.42,-590.6 908.42,-596.6 902.42,-596.6\"/>\n",
       "<text text-anchor=\"start\" x=\"644.88\" y=\"-573.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_CA.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-545.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.grain&#45;&gt;weekly_unique_users_CA.unique_users -->\n",
       "<g id=\"edge28\" class=\"edge\">\n",
       "<title>weekly_unique_users_CA.grain&#45;&gt;weekly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M548.98,-592.15C572.51,-589.28 597.69,-586.21 622.37,-583.2\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"622.66,-586.69 632.16,-582 621.81,-579.74 622.66,-586.69\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.unique_users -->\n",
       "<g id=\"node21\" class=\"node\">\n",
       "<title>daily_unique_users_CA.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M895.3,-760.6C895.3,-760.6 653.2,-760.6 653.2,-760.6 647.2,-760.6 641.2,-754.6 641.2,-748.6 641.2,-748.6 641.2,-709 641.2,-709 641.2,-703 647.2,-697 653.2,-697 653.2,-697 895.3,-697 895.3,-697 901.3,-697 907.3,-703 907.3,-709 907.3,-709 907.3,-748.6 907.3,-748.6 907.3,-754.6 901.3,-760.6 895.3,-760.6\"/>\n",
       "<text text-anchor=\"start\" x=\"652\" y=\"-737.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_CA.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-709.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.filtered_interactions&#45;&gt;daily_unique_users_CA.unique_users -->\n",
       "<g id=\"edge21\" class=\"edge\">\n",
       "<title>daily_unique_users_CA.filtered_interactions&#45;&gt;daily_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M589.89,-751.16C603.17,-749.54 616.58,-747.9 629.78,-746.29\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"629.81,-749.82 639.31,-745.13 628.96,-742.87 629.81,-749.82\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.region -->\n",
       "<g id=\"node9\" class=\"node\">\n",
       "<title>monthly_unique_users_CA.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M230.1,-227.6C230.1,-227.6 12,-227.6 12,-227.6 6,-227.6 0,-221.6 0,-215.6 0,-215.6 0,-176 0,-176 0,-170 6,-164 12,-164 12,-164 230.1,-164 230.1,-164 236.1,-164 242.1,-170 242.1,-176 242.1,-176 242.1,-215.6 242.1,-215.6 242.1,-221.6 236.1,-227.6 230.1,-227.6\"/>\n",
       "<text text-anchor=\"start\" x=\"10.8\" y=\"-204.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_CA.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-176.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.region&#45;&gt;monthly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge20\" class=\"edge\">\n",
       "<title>monthly_unique_users_CA.region&#45;&gt;monthly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M242.16,-195.8C247.88,-195.8 253.68,-195.8 259.51,-195.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"259.24,-199.3 269.24,-195.8 259.24,-192.3 259.24,-199.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.unique_users -->\n",
       "<g id=\"node10\" class=\"node\">\n",
       "<title>weekly_unique_users_US.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M902.05,-924.6C902.05,-924.6 646.45,-924.6 646.45,-924.6 640.45,-924.6 634.45,-918.6 634.45,-912.6 634.45,-912.6 634.45,-873 634.45,-873 634.45,-867 640.45,-861 646.45,-861 646.45,-861 902.05,-861 902.05,-861 908.05,-861 914.05,-867 914.05,-873 914.05,-873 914.05,-912.6 914.05,-912.6 914.05,-918.6 908.05,-924.6 902.05,-924.6\"/>\n",
       "<text text-anchor=\"start\" x=\"645.25\" y=\"-901.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_US.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-873.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.unique_users&#45;&gt;weekly_unique_users_US -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>weekly_unique_users_US.unique_users&#45;&gt;weekly_unique_users_US</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M914.52,-892.8C923.21,-892.8 931.86,-892.8 940.35,-892.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"940.3,-896.3 950.3,-892.8 940.3,-889.3 940.3,-896.3\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA -->\n",
       "<g id=\"node12\" class=\"node\">\n",
       "<title>monthly_unique_users_CA</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M1132.65,-247.6C1132.65,-247.6 959.55,-247.6 959.55,-247.6 953.55,-247.6 947.55,-241.6 947.55,-235.6 947.55,-235.6 947.55,-196 947.55,-196 947.55,-190 953.55,-184 959.55,-184 959.55,-184 1132.65,-184 1132.65,-184 1138.65,-184 1144.65,-190 1144.65,-196 1144.65,-196 1144.65,-235.6 1144.65,-235.6 1144.65,-241.6 1138.65,-247.6 1132.65,-247.6\"/>\n",
       "<text text-anchor=\"start\" x=\"958.35\" y=\"-224.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_CA</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-196.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.unique_users&#45;&gt;monthly_unique_users_CA -->\n",
       "<g id=\"edge13\" class=\"edge\">\n",
       "<title>monthly_unique_users_CA.unique_users&#45;&gt;monthly_unique_users_CA</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M918.87,-215.8C924.55,-215.8 930.2,-215.8 935.8,-215.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"935.68,-219.3 945.68,-215.8 935.68,-212.3 935.68,-219.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.filtered_interactions&#45;&gt;weekly_unique_users_CA.unique_users -->\n",
       "<g id=\"edge27\" class=\"edge\">\n",
       "<title>weekly_unique_users_CA.filtered_interactions&#45;&gt;weekly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M597.26,-543.34C605.63,-544.36 614.03,-545.38 622.37,-546.4\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"621.85,-549.86 632.2,-547.6 622.7,-542.92 621.85,-549.86\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.region -->\n",
       "<g id=\"node14\" class=\"node\">\n",
       "<title>daily_unique_users_CA.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M218.85,-801.6C218.85,-801.6 23.25,-801.6 23.25,-801.6 17.25,-801.6 11.25,-795.6 11.25,-789.6 11.25,-789.6 11.25,-750 11.25,-750 11.25,-744 17.25,-738 23.25,-738 23.25,-738 218.85,-738 218.85,-738 224.85,-738 230.85,-744 230.85,-750 230.85,-750 230.85,-789.6 230.85,-789.6 230.85,-795.6 224.85,-801.6 218.85,-801.6\"/>\n",
       "<text text-anchor=\"start\" x=\"22.05\" y=\"-778.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_CA.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-750.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.region&#45;&gt;daily_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>daily_unique_users_CA.region&#45;&gt;daily_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M231.07,-769.8C243.96,-769.8 257.32,-769.8 270.76,-769.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"270.54,-773.3 280.54,-769.8 270.54,-766.3 270.54,-773.3\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.filtered_interactions&#45;&gt;monthly_unique_users_US.unique_users -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>monthly_unique_users_US.filtered_interactions&#45;&gt;monthly_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M600.71,-421.84C606.86,-421.09 613.03,-420.34 619.17,-419.59\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"619.19,-423.11 628.69,-418.43 618.34,-416.16 619.19,-423.11\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.grain -->\n",
       "<g id=\"node17\" class=\"node\">\n",
       "<title>daily_unique_users_US.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M529.33,-145.6C529.33,-145.6 342.73,-145.6 342.73,-145.6 336.73,-145.6 330.73,-139.6 330.73,-133.6 330.73,-133.6 330.73,-94 330.73,-94 330.73,-88 336.73,-82 342.73,-82 342.73,-82 529.33,-82 529.33,-82 535.33,-82 541.33,-88 541.33,-94 541.33,-94 541.33,-133.6 541.33,-133.6 541.33,-139.6 535.33,-145.6 529.33,-145.6\"/>\n",
       "<text text-anchor=\"start\" x=\"341.53\" y=\"-122.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_US.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-94.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.grain&#45;&gt;daily_unique_users_US.unique_users -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>daily_unique_users_US.grain&#45;&gt;daily_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M541.57,-107.27C569.51,-105.53 600.21,-103.61 629.86,-101.76\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"629.89,-105.26 639.65,-101.14 629.45,-98.27 629.89,-105.26\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.filtered_interactions&#45;&gt;monthly_unique_users_CA.unique_users -->\n",
       "<g id=\"edge11\" class=\"edge\">\n",
       "<title>monthly_unique_users_CA.filtered_interactions&#45;&gt;monthly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M601.2,-205.57C606.99,-205.91 612.78,-206.25 618.56,-206.6\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"617.93,-210.07 628.12,-207.17 618.35,-203.08 617.93,-210.07\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.grain -->\n",
       "<g id=\"node19\" class=\"node\">\n",
       "<title>weekly_unique_users_US.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M536.45,-965.6C536.45,-965.6 335.6,-965.6 335.6,-965.6 329.6,-965.6 323.6,-959.6 323.6,-953.6 323.6,-953.6 323.6,-914 323.6,-914 323.6,-908 329.6,-902 335.6,-902 335.6,-902 536.45,-902 536.45,-902 542.45,-902 548.45,-908 548.45,-914 548.45,-914 548.45,-953.6 548.45,-953.6 548.45,-959.6 542.45,-965.6 536.45,-965.6\"/>\n",
       "<text text-anchor=\"start\" x=\"334.4\" y=\"-942.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_US.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-914.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.grain&#45;&gt;weekly_unique_users_US.unique_users -->\n",
       "<g id=\"edge10\" class=\"edge\">\n",
       "<title>weekly_unique_users_US.grain&#45;&gt;weekly_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M548.52,-920.2C572.41,-917.29 598.03,-914.17 623.12,-911.11\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"623.2,-914.62 632.71,-909.94 622.36,-907.67 623.2,-914.62\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.region -->\n",
       "<g id=\"node20\" class=\"node\">\n",
       "<title>monthly_unique_users_US.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M229.73,-432.6C229.73,-432.6 12.38,-432.6 12.38,-432.6 6.38,-432.6 0.38,-426.6 0.38,-420.6 0.38,-420.6 0.38,-381 0.38,-381 0.38,-375 6.38,-369 12.38,-369 12.38,-369 229.73,-369 229.73,-369 235.73,-369 241.73,-375 241.73,-381 241.73,-381 241.73,-420.6 241.73,-420.6 241.73,-426.6 235.73,-432.6 229.73,-432.6\"/>\n",
       "<text text-anchor=\"start\" x=\"11.18\" y=\"-409.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_US.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-381.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.region&#45;&gt;monthly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge17\" class=\"edge\">\n",
       "<title>monthly_unique_users_US.region&#45;&gt;monthly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M242.16,-416.53C247.94,-417.29 253.78,-418.06 259.67,-418.83\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"259.15,-422.29 269.52,-420.12 260.06,-415.35 259.15,-422.29\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA -->\n",
       "<g id=\"node25\" class=\"node\">\n",
       "<title>daily_unique_users_CA</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M1121.4,-760.6C1121.4,-760.6 970.8,-760.6 970.8,-760.6 964.8,-760.6 958.8,-754.6 958.8,-748.6 958.8,-748.6 958.8,-709 958.8,-709 958.8,-703 964.8,-697 970.8,-697 970.8,-697 1121.4,-697 1121.4,-697 1127.4,-697 1133.4,-703 1133.4,-709 1133.4,-709 1133.4,-748.6 1133.4,-748.6 1133.4,-754.6 1127.4,-760.6 1121.4,-760.6\"/>\n",
       "<text text-anchor=\"start\" x=\"969.6\" y=\"-737.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_CA</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-709.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.unique_users&#45;&gt;daily_unique_users_CA -->\n",
       "<g id=\"edge24\" class=\"edge\">\n",
       "<title>daily_unique_users_CA.unique_users&#45;&gt;daily_unique_users_CA</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M907.41,-728.8C920.84,-728.8 934.3,-728.8 947.27,-728.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"947.01,-732.3 957.01,-728.8 947.01,-725.3 947.01,-732.3\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.grain -->\n",
       "<g id=\"node23\" class=\"node\">\n",
       "<title>monthly_unique_users_US.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M540.58,-391.6C540.58,-391.6 331.48,-391.6 331.48,-391.6 325.48,-391.6 319.48,-385.6 319.48,-379.6 319.48,-379.6 319.48,-340 319.48,-340 319.48,-334 325.48,-328 331.48,-328 331.48,-328 540.58,-328 540.58,-328 546.58,-328 552.58,-334 552.58,-340 552.58,-340 552.58,-379.6 552.58,-379.6 552.58,-385.6 546.58,-391.6 540.58,-391.6\"/>\n",
       "<text text-anchor=\"start\" x=\"330.28\" y=\"-368.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_US.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-340.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.grain&#45;&gt;monthly_unique_users_US.unique_users -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>monthly_unique_users_US.grain&#45;&gt;monthly_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M552.73,-373.91C574.02,-376.51 596.56,-379.25 618.77,-381.96\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"618.14,-385.41 628.49,-383.15 618.99,-378.46 618.14,-385.41\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.grain -->\n",
       "<g id=\"node24\" class=\"node\">\n",
       "<title>daily_unique_users_CA.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M529.7,-719.6C529.7,-719.6 342.35,-719.6 342.35,-719.6 336.35,-719.6 330.35,-713.6 330.35,-707.6 330.35,-707.6 330.35,-668 330.35,-668 330.35,-662 336.35,-656 342.35,-656 342.35,-656 529.7,-656 529.7,-656 535.7,-656 541.7,-662 541.7,-668 541.7,-668 541.7,-707.6 541.7,-707.6 541.7,-713.6 535.7,-719.6 529.7,-719.6\"/>\n",
       "<text text-anchor=\"start\" x=\"341.15\" y=\"-696.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_CA.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-668.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.grain&#45;&gt;daily_unique_users_CA.unique_users -->\n",
       "<g id=\"edge22\" class=\"edge\">\n",
       "<title>daily_unique_users_CA.grain&#45;&gt;daily_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M542.03,-700.6C569.79,-703.99 600.24,-707.7 629.67,-711.29\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"629.03,-714.74 639.38,-712.48 629.88,-707.79 629.03,-714.74\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.region -->\n",
       "<g id=\"node26\" class=\"node\">\n",
       "<title>weekly_unique_users_US.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M225.6,-883.6C225.6,-883.6 16.5,-883.6 16.5,-883.6 10.5,-883.6 4.5,-877.6 4.5,-871.6 4.5,-871.6 4.5,-832 4.5,-832 4.5,-826 10.5,-820 16.5,-820 16.5,-820 225.6,-820 225.6,-820 231.6,-820 237.6,-826 237.6,-832 237.6,-832 237.6,-871.6 237.6,-871.6 237.6,-877.6 231.6,-883.6 225.6,-883.6\"/>\n",
       "<text text-anchor=\"start\" x=\"15.3\" y=\"-860.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_US.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-832.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.region&#45;&gt;weekly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge26\" class=\"edge\">\n",
       "<title>weekly_unique_users_US.region&#45;&gt;weekly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M237.7,-851.8C246.33,-851.8 255.14,-851.8 264.02,-851.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"263.77,-855.3 273.77,-851.8 263.77,-848.3 263.77,-855.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.region -->\n",
       "<g id=\"node27\" class=\"node\">\n",
       "<title>weekly_unique_users_CA.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M225.98,-596.6C225.98,-596.6 16.13,-596.6 16.13,-596.6 10.13,-596.6 4.13,-590.6 4.13,-584.6 4.13,-584.6 4.13,-545 4.13,-545 4.13,-539 10.13,-533 16.13,-533 16.13,-533 225.98,-533 225.98,-533 231.98,-533 237.98,-539 237.98,-545 237.98,-545 237.98,-584.6 237.98,-584.6 237.98,-590.6 231.98,-596.6 225.98,-596.6\"/>\n",
       "<text text-anchor=\"start\" x=\"14.93\" y=\"-573.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_CA.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-545.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.region&#45;&gt;weekly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge15\" class=\"edge\">\n",
       "<title>weekly_unique_users_CA.region&#45;&gt;weekly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M238.15,-549.59C246.49,-548.5 255,-547.38 263.57,-546.26\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"263.91,-549.75 273.37,-544.98 263,-542.81 263.91,-549.75\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.filtered_interactions&#45;&gt;weekly_unique_users_US.unique_users -->\n",
       "<g id=\"edge9\" class=\"edge\">\n",
       "<title>weekly_unique_users_US.filtered_interactions&#45;&gt;weekly_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M596.77,-871.28C605.43,-872.34 614.12,-873.39 622.74,-874.45\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"622.19,-877.9 632.54,-875.64 623.03,-870.96 622.19,-877.9\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.unique_users&#45;&gt;weekly_unique_users_CA -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>weekly_unique_users_CA.unique_users&#45;&gt;weekly_unique_users_CA</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M914.92,-564.8C923.31,-564.8 931.68,-564.8 939.89,-564.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"939.87,-568.3 949.87,-564.8 939.87,-561.3 939.87,-568.3\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.region -->\n",
       "<g id=\"node30\" class=\"node\">\n",
       "<title>daily_unique_users_US.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M218.48,-63.6C218.48,-63.6 23.63,-63.6 23.63,-63.6 17.63,-63.6 11.63,-57.6 11.63,-51.6 11.63,-51.6 11.63,-12 11.63,-12 11.63,-6 17.63,0 23.63,0 23.63,0 218.48,0 218.48,0 224.48,0 230.48,-6 230.48,-12 230.48,-12 230.48,-51.6 230.48,-51.6 230.48,-57.6 224.48,-63.6 218.48,-63.6\"/>\n",
       "<text text-anchor=\"start\" x=\"22.43\" y=\"-40.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_US.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.region&#45;&gt;daily_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge30\" class=\"edge\">\n",
       "<title>daily_unique_users_US.region&#45;&gt;daily_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M230.64,-31.8C243.67,-31.8 257.19,-31.8 270.8,-31.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"270.72,-35.3 280.72,-31.8 270.72,-28.3 270.72,-35.3\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.filtered_interactions&#45;&gt;daily_unique_users_US.unique_users -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>daily_unique_users_US.filtered_interactions&#45;&gt;daily_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M589.4,-59.44C602.9,-61.89 616.55,-64.37 629.97,-66.81\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"629.24,-70.23 639.71,-68.57 630.49,-63.34 629.24,-70.23\"/>\n",
       "</g>\n",
       "<!-- function -->\n",
       "<g id=\"node32\" class=\"node\">\n",
       "<title>function</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M143.48,-938.47C143.48,-938.47 98.63,-938.47 98.63,-938.47 92.63,-938.47 86.63,-932.47 86.63,-926.47 86.63,-926.47 86.63,-913.12 86.63,-913.12 86.63,-907.12 92.63,-901.12 98.63,-901.12 98.63,-901.12 143.48,-901.12 143.48,-901.12 149.48,-901.12 155.48,-907.12 155.48,-913.12 155.48,-913.12 155.48,-926.47 155.48,-926.47 155.48,-932.47 149.48,-938.47 143.48,-938.47\"/>\n",
       "<text text-anchor=\"middle\" x=\"121.05\" y=\"-914.38\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">function</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x19f4cbadc50>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%%cell_to_module reusable_subdags --display\n",
    "import pandas as pd\n",
    "import unique_users\n",
    "\n",
    "from hamilton.function_modifiers import subdag, value\n",
    "\n",
    "\n",
    "def website_interactions() -> pd.DataFrame:\n",
    "    \"\"\"Gives event-driven data with a series\n",
    "\n",
    "    :return: Some mock event data.\n",
    "    \"\"\"\n",
    "    data = [\n",
    "        (\"20220901-14:00:00\", 1, \"US\"),\n",
    "        (\"20220901-18:30:00\", 2, \"US\"),\n",
    "        (\"20220901-19:00:00\", 1, \"US\"),\n",
    "        (\"20220902-08:00:00\", 3, \"US\"),\n",
    "        (\"20220903-16:00:00\", 1, \"US\"),\n",
    "        (\"20220907-13:00:00\", 4, \"US\"),\n",
    "        (\"20220910-14:00:00\", 1, \"US\"),\n",
    "        (\"20220911-12:00:00\", 3, \"US\"),\n",
    "        (\"20220914-11:00:00\", 1, \"US\"),\n",
    "        (\"20220915-07:30:00\", 2, \"US\"),\n",
    "        (\"20220916-06:00:00\", 1, \"US\"),\n",
    "        (\"20220917-16:00:00\", 2, \"US\"),\n",
    "        (\"20220920-17:00:00\", 5, \"US\"),\n",
    "        (\"20220922-09:30:00\", 2, \"US\"),\n",
    "        (\"20220922-10:00:00\", 1, \"US\"),\n",
    "        (\"20220924-07:00:00\", 6, \"US\"),\n",
    "        (\"20220924-08:00:00\", 1, \"US\"),\n",
    "        (\"20220925-21:00:00\", 1, \"US\"),\n",
    "        (\"20220926-15:30:00\", 2, \"US\"),\n",
    "        (\"20220901-14:00:00\", 7, \"CA\"),\n",
    "        (\"20220901-18:30:00\", 8, \"CA\"),\n",
    "        (\"20220901-19:00:00\", 9, \"CA\"),\n",
    "        (\"20220902-08:00:00\", 7, \"CA\"),\n",
    "        (\"20220903-16:00:00\", 10, \"CA\"),\n",
    "        (\"20220907-13:00:00\", 9, \"CA\"),\n",
    "        (\"20220910-14:00:00\", 8, \"CA\"),\n",
    "        (\"20220911-12:00:00\", 11, \"CA\"),\n",
    "        (\"20220914-11:00:00\", 12, \"CA\"),\n",
    "        (\"20220915-07:30:00\", 7, \"CA\"),\n",
    "        (\"20220916-06:00:00\", 9, \"CA\"),\n",
    "        (\"20220917-16:00:00\", 10, \"CA\"),\n",
    "        (\"20220920-17:00:00\", 7, \"CA\"),\n",
    "        (\"20220922-09:30:00\", 11, \"CA\"),\n",
    "        (\"20220922-10:00:00\", 8, \"CA\"),\n",
    "        (\"20220924-07:00:00\", 9, \"CA\"),\n",
    "        (\"20220924-08:00:00\", 10, \"CA\"),\n",
    "        (\"20220925-21:00:00\", 13, \"CA\"),\n",
    "        (\"20220926-15:30:00\", 14, \"CA\"),\n",
    "    ]\n",
    "    df = (\n",
    "        pd.DataFrame(data, columns=[\"timestamp\", \"user_id\", \"region\"])\n",
    "        .set_index(\"timestamp\")\n",
    "        .sort_index()\n",
    "    )\n",
    "    df.index = pd.DatetimeIndex(df.index)\n",
    "    return df\n",
    "\n",
    "\n",
    "@subdag(\n",
    "    unique_users,\n",
    "    inputs={\"grain\": value(\"day\")},\n",
    "    config={\"region\": \"US\"},\n",
    ")\n",
    "def daily_unique_users_US(unique_users: pd.Series) -> pd.Series:\n",
    "    return unique_users\n",
    "\n",
    "\n",
    "@subdag(\n",
    "    unique_users,\n",
    "    inputs={\"grain\": value(\"week\")},\n",
    "    config={\"region\": \"US\"},\n",
    ")\n",
    "def weekly_unique_users_US(unique_users: pd.Series) -> pd.Series:\n",
    "    return unique_users\n",
    "\n",
    "\n",
    "@subdag(\n",
    "    unique_users,\n",
    "    inputs={\"grain\": value(\"month\")},\n",
    "    config={\"region\": \"US\"},\n",
    ")\n",
    "def monthly_unique_users_US(unique_users: pd.Series) -> pd.Series:\n",
    "    return unique_users\n",
    "\n",
    "\n",
    "@subdag(\n",
    "    unique_users,\n",
    "    inputs={\"grain\": value(\"day\")},\n",
    "    config={\"region\": \"CA\"},\n",
    ")\n",
    "def daily_unique_users_CA(unique_users: pd.Series) -> pd.Series:\n",
    "    return unique_users\n",
    "\n",
    "\n",
    "@subdag(\n",
    "    unique_users,\n",
    "    inputs={\"grain\": value(\"week\")},\n",
    "    config={\"region\": \"CA\"},\n",
    ")\n",
    "def weekly_unique_users_CA(unique_users: pd.Series) -> pd.Series:\n",
    "    return unique_users\n",
    "\n",
    "\n",
    "@subdag(\n",
    "    unique_users,\n",
    "    inputs={\"grain\": value(\"month\")},\n",
    "    config={\"region\": \"CA\"},\n",
    ")\n",
    "def monthly_unique_users_CA(unique_users: pd.Series) -> pd.Series:\n",
    "    return unique_users"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\obeng\\AppData\\Local\\Temp\\tmpvmsp6sci.py:18: FutureWarning: 'M' is deprecated and will be removed in a future version, please use 'ME' instead.\n",
      "  return filtered_interactions.resample(_grain_mapping[grain])[\"user_id\"].nunique()\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "            daily_unique_users_US  daily_unique_users_CA  \\\n",
      "timestamp                                                  \n",
      "2022-09-01                    2.0                    3.0   \n",
      "2022-09-02                    1.0                    1.0   \n",
      "2022-09-03                    1.0                    1.0   \n",
      "2022-09-04                    0.0                    0.0   \n",
      "2022-09-05                    0.0                    0.0   \n",
      "2022-09-06                    0.0                    0.0   \n",
      "2022-09-07                    1.0                    1.0   \n",
      "2022-09-08                    0.0                    0.0   \n",
      "2022-09-09                    0.0                    0.0   \n",
      "2022-09-10                    1.0                    1.0   \n",
      "2022-09-11                    1.0                    1.0   \n",
      "2022-09-12                    0.0                    0.0   \n",
      "2022-09-13                    0.0                    0.0   \n",
      "2022-09-14                    1.0                    1.0   \n",
      "2022-09-15                    1.0                    1.0   \n",
      "2022-09-16                    1.0                    1.0   \n",
      "2022-09-17                    1.0                    1.0   \n",
      "2022-09-18                    0.0                    0.0   \n",
      "2022-09-19                    0.0                    0.0   \n",
      "2022-09-20                    1.0                    1.0   \n",
      "2022-09-21                    0.0                    0.0   \n",
      "2022-09-22                    2.0                    2.0   \n",
      "2022-09-23                    0.0                    0.0   \n",
      "2022-09-24                    2.0                    2.0   \n",
      "2022-09-25                    1.0                    1.0   \n",
      "2022-09-26                    1.0                    1.0   \n",
      "2022-09-27                    NaN                    NaN   \n",
      "2022-09-28                    NaN                    NaN   \n",
      "2022-09-29                    NaN                    NaN   \n",
      "2022-09-30                    NaN                    NaN   \n",
      "2022-10-01                    NaN                    NaN   \n",
      "2022-10-02                    NaN                    NaN   \n",
      "\n",
      "            weekly_unique_users_US  weekly_unique_users_CA  \\\n",
      "timestamp                                                    \n",
      "2022-09-01                     3.0                     4.0   \n",
      "2022-09-02                     3.0                     4.0   \n",
      "2022-09-03                     3.0                     4.0   \n",
      "2022-09-04                     3.0                     4.0   \n",
      "2022-09-05                     3.0                     3.0   \n",
      "2022-09-06                     3.0                     3.0   \n",
      "2022-09-07                     3.0                     3.0   \n",
      "2022-09-08                     3.0                     3.0   \n",
      "2022-09-09                     3.0                     3.0   \n",
      "2022-09-10                     3.0                     3.0   \n",
      "2022-09-11                     3.0                     3.0   \n",
      "2022-09-12                     2.0                     4.0   \n",
      "2022-09-13                     2.0                     4.0   \n",
      "2022-09-14                     2.0                     4.0   \n",
      "2022-09-15                     2.0                     4.0   \n",
      "2022-09-16                     2.0                     4.0   \n",
      "2022-09-17                     2.0                     4.0   \n",
      "2022-09-18                     2.0                     4.0   \n",
      "2022-09-19                     4.0                     6.0   \n",
      "2022-09-20                     4.0                     6.0   \n",
      "2022-09-21                     4.0                     6.0   \n",
      "2022-09-22                     4.0                     6.0   \n",
      "2022-09-23                     4.0                     6.0   \n",
      "2022-09-24                     4.0                     6.0   \n",
      "2022-09-25                     4.0                     6.0   \n",
      "2022-09-26                     1.0                     1.0   \n",
      "2022-09-27                     1.0                     1.0   \n",
      "2022-09-28                     1.0                     1.0   \n",
      "2022-09-29                     1.0                     1.0   \n",
      "2022-09-30                     1.0                     1.0   \n",
      "2022-10-01                     1.0                     1.0   \n",
      "2022-10-02                     1.0                     1.0   \n",
      "\n",
      "            monthly_unique_users_US  monthly_unique_users_CA  \n",
      "timestamp                                                     \n",
      "2022-09-01                      6.0                      8.0  \n",
      "2022-09-02                      6.0                      8.0  \n",
      "2022-09-03                      6.0                      8.0  \n",
      "2022-09-04                      6.0                      8.0  \n",
      "2022-09-05                      6.0                      8.0  \n",
      "2022-09-06                      6.0                      8.0  \n",
      "2022-09-07                      6.0                      8.0  \n",
      "2022-09-08                      6.0                      8.0  \n",
      "2022-09-09                      6.0                      8.0  \n",
      "2022-09-10                      6.0                      8.0  \n",
      "2022-09-11                      6.0                      8.0  \n",
      "2022-09-12                      6.0                      8.0  \n",
      "2022-09-13                      6.0                      8.0  \n",
      "2022-09-14                      6.0                      8.0  \n",
      "2022-09-15                      6.0                      8.0  \n",
      "2022-09-16                      6.0                      8.0  \n",
      "2022-09-17                      6.0                      8.0  \n",
      "2022-09-18                      6.0                      8.0  \n",
      "2022-09-19                      6.0                      8.0  \n",
      "2022-09-20                      6.0                      8.0  \n",
      "2022-09-21                      6.0                      8.0  \n",
      "2022-09-22                      6.0                      8.0  \n",
      "2022-09-23                      6.0                      8.0  \n",
      "2022-09-24                      6.0                      8.0  \n",
      "2022-09-25                      6.0                      8.0  \n",
      "2022-09-26                      6.0                      8.0  \n",
      "2022-09-27                      6.0                      8.0  \n",
      "2022-09-28                      6.0                      8.0  \n",
      "2022-09-29                      6.0                      8.0  \n",
      "2022-09-30                      6.0                      8.0  \n",
      "2022-10-01                      NaN                      NaN  \n",
      "2022-10-02                      NaN                      NaN  \n"
     ]
    },
    {
     "data": {
      "image/svg+xml": [
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
       "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
       " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
       "<!-- Generated by graphviz version 12.1.0 (20240811.2233)\n",
       " -->\n",
       "<!-- Pages: 1 -->\n",
       "<svg width=\"1153pt\" height=\"1041pt\"\n",
       " viewBox=\"0.00 0.00 1152.65 1040.80\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
       "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 1036.8)\">\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-1036.8 1148.65,-1036.8 1148.65,4 -4,4\"/>\n",
       "<g id=\"clust1\" class=\"cluster\">\n",
       "<title>cluster__legend</title>\n",
       "<polygon fill=\"#ffffff\" stroke=\"black\" points=\"78.62,-892.8 78.62,-1024.8 163.48,-1024.8 163.48,-892.8 78.62,-892.8\"/>\n",
       "<text text-anchor=\"middle\" x=\"121.05\" y=\"-1007.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">Legend</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.region -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>daily_unique_users_US.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M218.48,-883.6C218.48,-883.6 23.63,-883.6 23.63,-883.6 17.63,-883.6 11.63,-877.6 11.63,-871.6 11.63,-871.6 11.63,-832 11.63,-832 11.63,-826 17.63,-820 23.63,-820 23.63,-820 218.48,-820 218.48,-820 224.48,-820 230.48,-826 230.48,-832 230.48,-832 230.48,-871.6 230.48,-871.6 230.48,-877.6 224.48,-883.6 218.48,-883.6\"/>\n",
       "<text text-anchor=\"start\" x=\"22.43\" y=\"-860.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_US.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-832.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.filtered_interactions -->\n",
       "<g id=\"node30\" class=\"node\">\n",
       "<title>daily_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M577.33,-883.6C577.33,-883.6 294.73,-883.6 294.73,-883.6 288.73,-883.6 282.73,-877.6 282.73,-871.6 282.73,-871.6 282.73,-832 282.73,-832 282.73,-826 288.73,-820 294.73,-820 294.73,-820 577.33,-820 577.33,-820 583.33,-820 589.33,-826 589.33,-832 589.33,-832 589.33,-871.6 589.33,-871.6 589.33,-877.6 583.33,-883.6 577.33,-883.6\"/>\n",
       "<text text-anchor=\"start\" x=\"293.53\" y=\"-860.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_US.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-832.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.region&#45;&gt;daily_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge29\" class=\"edge\">\n",
       "<title>daily_unique_users_US.region&#45;&gt;daily_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M230.64,-851.8C243.67,-851.8 257.19,-851.8 270.8,-851.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"270.72,-855.3 280.72,-851.8 270.72,-848.3 270.72,-855.3\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.grain -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>daily_unique_users_US.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M529.33,-965.6C529.33,-965.6 342.73,-965.6 342.73,-965.6 336.73,-965.6 330.73,-959.6 330.73,-953.6 330.73,-953.6 330.73,-914 330.73,-914 330.73,-908 336.73,-902 342.73,-902 342.73,-902 529.33,-902 529.33,-902 535.33,-902 541.33,-908 541.33,-914 541.33,-914 541.33,-953.6 541.33,-953.6 541.33,-959.6 535.33,-965.6 529.33,-965.6\"/>\n",
       "<text text-anchor=\"start\" x=\"341.53\" y=\"-942.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_US.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-914.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.unique_users -->\n",
       "<g id=\"node7\" class=\"node\">\n",
       "<title>daily_unique_users_US.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M894.92,-924.6C894.92,-924.6 653.58,-924.6 653.58,-924.6 647.58,-924.6 641.58,-918.6 641.58,-912.6 641.58,-912.6 641.58,-873 641.58,-873 641.58,-867 647.58,-861 653.58,-861 653.58,-861 894.92,-861 894.92,-861 900.92,-861 906.92,-867 906.92,-873 906.92,-873 906.92,-912.6 906.92,-912.6 906.92,-918.6 900.92,-924.6 894.92,-924.6\"/>\n",
       "<text text-anchor=\"start\" x=\"652.38\" y=\"-901.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_US.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-873.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.grain&#45;&gt;daily_unique_users_US.unique_users -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>daily_unique_users_US.grain&#45;&gt;daily_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M541.57,-921.05C569.51,-917.64 600.21,-913.9 629.86,-910.29\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"630.16,-913.78 639.66,-909.09 629.31,-906.83 630.16,-913.78\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.grain -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>weekly_unique_users_US.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M536.45,-473.6C536.45,-473.6 335.6,-473.6 335.6,-473.6 329.6,-473.6 323.6,-467.6 323.6,-461.6 323.6,-461.6 323.6,-422 323.6,-422 323.6,-416 329.6,-410 335.6,-410 335.6,-410 536.45,-410 536.45,-410 542.45,-410 548.45,-416 548.45,-422 548.45,-422 548.45,-461.6 548.45,-461.6 548.45,-467.6 542.45,-473.6 536.45,-473.6\"/>\n",
       "<text text-anchor=\"start\" x=\"334.4\" y=\"-450.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_US.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-422.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.unique_users -->\n",
       "<g id=\"node19\" class=\"node\">\n",
       "<title>weekly_unique_users_US.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M902.05,-432.6C902.05,-432.6 646.45,-432.6 646.45,-432.6 640.45,-432.6 634.45,-426.6 634.45,-420.6 634.45,-420.6 634.45,-381 634.45,-381 634.45,-375 640.45,-369 646.45,-369 646.45,-369 902.05,-369 902.05,-369 908.05,-369 914.05,-375 914.05,-381 914.05,-381 914.05,-420.6 914.05,-420.6 914.05,-426.6 908.05,-432.6 902.05,-432.6\"/>\n",
       "<text text-anchor=\"start\" x=\"645.25\" y=\"-409.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_US.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-381.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.grain&#45;&gt;weekly_unique_users_US.unique_users -->\n",
       "<g id=\"edge15\" class=\"edge\">\n",
       "<title>weekly_unique_users_US.grain&#45;&gt;weekly_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M548.52,-428.2C572.41,-425.29 598.03,-422.17 623.12,-419.11\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"623.2,-422.62 632.71,-417.94 622.36,-415.67 623.2,-422.62\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>monthly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M588.95,-801.6C588.95,-801.6 283.1,-801.6 283.1,-801.6 277.1,-801.6 271.1,-795.6 271.1,-789.6 271.1,-789.6 271.1,-750 271.1,-750 271.1,-744 277.1,-738 283.1,-738 283.1,-738 588.95,-738 588.95,-738 594.95,-738 600.95,-744 600.95,-750 600.95,-750 600.95,-789.6 600.95,-789.6 600.95,-795.6 594.95,-801.6 588.95,-801.6\"/>\n",
       "<text text-anchor=\"start\" x=\"281.9\" y=\"-778.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_CA.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-750.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.unique_users -->\n",
       "<g id=\"node20\" class=\"node\">\n",
       "<title>monthly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M906.55,-760.6C906.55,-760.6 641.95,-760.6 641.95,-760.6 635.95,-760.6 629.95,-754.6 629.95,-748.6 629.95,-748.6 629.95,-709 629.95,-709 629.95,-703 635.95,-697 641.95,-697 641.95,-697 906.55,-697 906.55,-697 912.55,-697 918.55,-703 918.55,-709 918.55,-709 918.55,-748.6 918.55,-748.6 918.55,-754.6 912.55,-760.6 906.55,-760.6\"/>\n",
       "<text text-anchor=\"start\" x=\"640.75\" y=\"-737.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_CA.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-709.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.filtered_interactions&#45;&gt;monthly_unique_users_CA.unique_users -->\n",
       "<g id=\"edge16\" class=\"edge\">\n",
       "<title>monthly_unique_users_CA.filtered_interactions&#45;&gt;monthly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M601.2,-749.78C606.99,-749.07 612.78,-748.37 618.56,-747.66\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"618.63,-751.18 628.13,-746.5 617.78,-744.23 618.63,-751.18\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>weekly_unique_users_US</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M1128.15,-432.6C1128.15,-432.6 964.05,-432.6 964.05,-432.6 958.05,-432.6 952.05,-426.6 952.05,-420.6 952.05,-420.6 952.05,-381 952.05,-381 952.05,-375 958.05,-369 964.05,-369 964.05,-369 1128.15,-369 1128.15,-369 1134.15,-369 1140.15,-375 1140.15,-381 1140.15,-381 1140.15,-420.6 1140.15,-420.6 1140.15,-426.6 1134.15,-432.6 1128.15,-432.6\"/>\n",
       "<text text-anchor=\"start\" x=\"962.85\" y=\"-409.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_US</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-381.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.grain -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>monthly_unique_users_CA.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M540.95,-719.6C540.95,-719.6 331.1,-719.6 331.1,-719.6 325.1,-719.6 319.1,-713.6 319.1,-707.6 319.1,-707.6 319.1,-668 319.1,-668 319.1,-662 325.1,-656 331.1,-656 331.1,-656 540.95,-656 540.95,-656 546.95,-656 552.95,-662 552.95,-668 552.95,-668 552.95,-707.6 552.95,-707.6 552.95,-713.6 546.95,-719.6 540.95,-719.6\"/>\n",
       "<text text-anchor=\"start\" x=\"329.9\" y=\"-696.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_CA.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-668.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.grain&#45;&gt;monthly_unique_users_CA.unique_users -->\n",
       "<g id=\"edge17\" class=\"edge\">\n",
       "<title>monthly_unique_users_CA.grain&#45;&gt;monthly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M553.21,-701.97C574.14,-704.52 596.26,-707.22 618.09,-709.88\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"617.62,-713.35 627.97,-711.08 618.47,-706.4 617.62,-713.35\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_US -->\n",
       "<g id=\"node31\" class=\"node\">\n",
       "<title>daily_unique_users_US</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M1121.03,-924.6C1121.03,-924.6 971.18,-924.6 971.18,-924.6 965.18,-924.6 959.18,-918.6 959.18,-912.6 959.18,-912.6 959.18,-873 959.18,-873 959.18,-867 965.18,-861 971.18,-861 971.18,-861 1121.03,-861 1121.03,-861 1127.03,-861 1133.03,-867 1133.03,-873 1133.03,-873 1133.03,-912.6 1133.03,-912.6 1133.03,-918.6 1127.03,-924.6 1121.03,-924.6\"/>\n",
       "<text text-anchor=\"start\" x=\"969.98\" y=\"-901.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_US</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-873.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.unique_users&#45;&gt;daily_unique_users_US -->\n",
       "<g id=\"edge30\" class=\"edge\">\n",
       "<title>daily_unique_users_US.unique_users&#45;&gt;daily_unique_users_US</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M907.41,-892.8C920.94,-892.8 934.51,-892.8 947.57,-892.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"947.38,-896.3 957.38,-892.8 947.38,-889.3 947.38,-896.3\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.unique_users -->\n",
       "<g id=\"node8\" class=\"node\">\n",
       "<title>monthly_unique_users_US.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M906.17,-124.6C906.17,-124.6 642.33,-124.6 642.33,-124.6 636.33,-124.6 630.33,-118.6 630.33,-112.6 630.33,-112.6 630.33,-73 630.33,-73 630.33,-67 636.33,-61 642.33,-61 642.33,-61 906.17,-61 906.17,-61 912.17,-61 918.17,-67 918.17,-73 918.17,-73 918.17,-112.6 918.17,-112.6 918.17,-118.6 912.17,-124.6 906.17,-124.6\"/>\n",
       "<text text-anchor=\"start\" x=\"641.12\" y=\"-101.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_US.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-73.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US -->\n",
       "<g id=\"node13\" class=\"node\">\n",
       "<title>monthly_unique_users_US</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M1132.28,-124.6C1132.28,-124.6 959.93,-124.6 959.93,-124.6 953.93,-124.6 947.93,-118.6 947.93,-112.6 947.93,-112.6 947.93,-73 947.93,-73 947.93,-67 953.93,-61 959.93,-61 959.93,-61 1132.28,-61 1132.28,-61 1138.28,-61 1144.28,-67 1144.28,-73 1144.28,-73 1144.28,-112.6 1144.28,-112.6 1144.28,-118.6 1138.28,-124.6 1132.28,-124.6\"/>\n",
       "<text text-anchor=\"start\" x=\"958.73\" y=\"-101.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_US</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-73.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.unique_users&#45;&gt;monthly_unique_users_US -->\n",
       "<g id=\"edge11\" class=\"edge\">\n",
       "<title>monthly_unique_users_US.unique_users&#45;&gt;monthly_unique_users_US</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M918.47,-92.8C924.47,-92.8 930.44,-92.8 936.35,-92.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"936.09,-96.3 946.09,-92.8 936.09,-89.3 936.09,-96.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA -->\n",
       "<g id=\"node9\" class=\"node\">\n",
       "<title>weekly_unique_users_CA</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M1128.53,-247.6C1128.53,-247.6 963.68,-247.6 963.68,-247.6 957.68,-247.6 951.68,-241.6 951.68,-235.6 951.68,-235.6 951.68,-196 951.68,-196 951.68,-190 957.68,-184 963.68,-184 963.68,-184 1128.53,-184 1128.53,-184 1134.53,-184 1140.53,-190 1140.53,-196 1140.53,-196 1140.53,-235.6 1140.53,-235.6 1140.53,-241.6 1134.53,-247.6 1128.53,-247.6\"/>\n",
       "<text text-anchor=\"start\" x=\"962.48\" y=\"-224.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_CA</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-196.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.region -->\n",
       "<g id=\"node10\" class=\"node\">\n",
       "<title>monthly_unique_users_US.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M229.73,-63.6C229.73,-63.6 12.38,-63.6 12.38,-63.6 6.38,-63.6 0.38,-57.6 0.38,-51.6 0.38,-51.6 0.38,-12 0.38,-12 0.38,-6 6.38,0 12.38,0 12.38,0 229.73,0 229.73,0 235.73,0 241.73,-6 241.73,-12 241.73,-12 241.73,-51.6 241.73,-51.6 241.73,-57.6 235.73,-63.6 229.73,-63.6\"/>\n",
       "<text text-anchor=\"start\" x=\"11.18\" y=\"-40.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_US.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"node29\" class=\"node\">\n",
       "<title>monthly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M588.58,-63.6C588.58,-63.6 283.48,-63.6 283.48,-63.6 277.48,-63.6 271.48,-57.6 271.48,-51.6 271.48,-51.6 271.48,-12 271.48,-12 271.48,-6 277.48,0 283.48,0 283.48,0 588.58,0 588.58,0 594.58,0 600.58,-6 600.58,-12 600.58,-12 600.58,-51.6 600.58,-51.6 600.58,-57.6 594.58,-63.6 588.58,-63.6\"/>\n",
       "<text text-anchor=\"start\" x=\"282.28\" y=\"-40.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_US.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.region&#45;&gt;monthly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge27\" class=\"edge\">\n",
       "<title>monthly_unique_users_US.region&#45;&gt;monthly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M242.16,-31.8C247.94,-31.8 253.78,-31.8 259.67,-31.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"259.5,-35.3 269.5,-31.8 259.5,-28.3 259.5,-35.3\"/>\n",
       "</g>\n",
       "<!-- website_interactions -->\n",
       "<g id=\"node11\" class=\"node\">\n",
       "<title>website_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M186.98,-514.6C186.98,-514.6 55.13,-514.6 55.13,-514.6 49.13,-514.6 43.13,-508.6 43.13,-502.6 43.13,-502.6 43.13,-463 43.13,-463 43.13,-457 49.13,-451 55.13,-451 55.13,-451 186.98,-451 186.98,-451 192.98,-451 198.98,-457 198.98,-463 198.98,-463 198.98,-502.6 198.98,-502.6 198.98,-508.6 192.98,-514.6 186.98,-514.6\"/>\n",
       "<text text-anchor=\"start\" x=\"53.93\" y=\"-491.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">website_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"86.93\" y=\"-463.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;monthly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge1\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;monthly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M188.71,-515C208.79,-527.82 228.96,-544.44 242.1,-564.8 282.25,-626.99 220.63,-674.66 271.1,-728.8 271.48,-729.2 271.85,-729.6 272.24,-730\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"269.85,-732.56 279.59,-736.74 274.58,-727.4 269.85,-732.56\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"node16\" class=\"node\">\n",
       "<title>daily_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M577.7,-637.6C577.7,-637.6 294.35,-637.6 294.35,-637.6 288.35,-637.6 282.35,-631.6 282.35,-625.6 282.35,-625.6 282.35,-586 282.35,-586 282.35,-580 288.35,-574 294.35,-574 294.35,-574 577.7,-574 577.7,-574 583.7,-574 589.7,-580 589.7,-586 589.7,-586 589.7,-625.6 589.7,-625.6 589.7,-631.6 583.7,-637.6 577.7,-637.6\"/>\n",
       "<text text-anchor=\"start\" x=\"293.15\" y=\"-614.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_CA.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-586.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;daily_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge12\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;daily_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M172.88,-515.05C200.97,-531.76 237.01,-551.42 271.1,-564.8 275.55,-566.55 280.11,-568.24 284.73,-569.88\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"283.59,-573.19 294.18,-573.1 285.85,-566.56 283.59,-573.19\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"node24\" class=\"node\">\n",
       "<title>weekly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M584.45,-391.6C584.45,-391.6 287.6,-391.6 287.6,-391.6 281.6,-391.6 275.6,-385.6 275.6,-379.6 275.6,-379.6 275.6,-340 275.6,-340 275.6,-334 281.6,-328 287.6,-328 287.6,-328 584.45,-328 584.45,-328 590.45,-328 596.45,-334 596.45,-340 596.45,-340 596.45,-379.6 596.45,-379.6 596.45,-385.6 590.45,-391.6 584.45,-391.6\"/>\n",
       "<text text-anchor=\"start\" x=\"286.4\" y=\"-368.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_US.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-340.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;weekly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge19\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;weekly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M172.88,-450.55C200.97,-433.84 237.01,-414.18 271.1,-400.8 275.55,-399.05 280.11,-397.36 284.73,-395.72\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"285.85,-399.04 294.18,-392.5 283.59,-392.41 285.85,-399.04\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"node26\" class=\"node\">\n",
       "<title>weekly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M584.83,-227.6C584.83,-227.6 287.23,-227.6 287.23,-227.6 281.23,-227.6 275.23,-221.6 275.23,-215.6 275.23,-215.6 275.23,-176 275.23,-176 275.23,-170 281.23,-164 287.23,-164 287.23,-164 584.83,-164 584.83,-164 590.83,-164 596.83,-170 596.83,-176 596.83,-176 596.83,-215.6 596.83,-215.6 596.83,-221.6 590.83,-227.6 584.83,-227.6\"/>\n",
       "<text text-anchor=\"start\" x=\"286.03\" y=\"-204.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_CA.filtered_interactions</text>\n",
       "<text text-anchor=\"start\" x=\"401.9\" y=\"-176.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">DataFrame</text>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;weekly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge22\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;weekly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M188.71,-450.6C208.79,-437.78 228.96,-421.16 242.1,-400.8 282.25,-338.61 220.63,-290.94 271.1,-236.8 271.48,-236.4 271.85,-236 272.24,-235.6\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"274.58,-238.2 279.59,-228.86 269.85,-233.04 274.58,-238.2\"/>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;monthly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge26\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;monthly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M190.71,-450.64C210.53,-437.94 230.04,-421.38 242.1,-400.8 279.08,-337.66 223.57,-128.44 271.1,-72.8 271.27,-72.6 271.43,-72.41 271.6,-72.22\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"274.05,-74.72 278.6,-65.15 269.08,-69.79 274.05,-74.72\"/>\n",
       "</g>\n",
       "<!-- website_interactions&#45;&gt;daily_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge28\" class=\"edge\">\n",
       "<title>website_interactions&#45;&gt;daily_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M190.04,-514.97C209.95,-527.71 229.68,-544.29 242.1,-564.8 299.12,-658.97 198.38,-728.14 271.1,-810.8 272.08,-811.92 273.09,-813 274.12,-814.06\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"271.59,-816.5 281.34,-820.64 276.3,-811.32 271.59,-816.5\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.unique_users -->\n",
       "<g id=\"node12\" class=\"node\">\n",
       "<title>daily_unique_users_CA.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M895.3,-596.6C895.3,-596.6 653.2,-596.6 653.2,-596.6 647.2,-596.6 641.2,-590.6 641.2,-584.6 641.2,-584.6 641.2,-545 641.2,-545 641.2,-539 647.2,-533 653.2,-533 653.2,-533 895.3,-533 895.3,-533 901.3,-533 907.3,-539 907.3,-545 907.3,-545 907.3,-584.6 907.3,-584.6 907.3,-590.6 901.3,-596.6 895.3,-596.6\"/>\n",
       "<text text-anchor=\"start\" x=\"652\" y=\"-573.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_CA.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-545.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA -->\n",
       "<g id=\"node21\" class=\"node\">\n",
       "<title>daily_unique_users_CA</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M1121.4,-596.6C1121.4,-596.6 970.8,-596.6 970.8,-596.6 964.8,-596.6 958.8,-590.6 958.8,-584.6 958.8,-584.6 958.8,-545 958.8,-545 958.8,-539 964.8,-533 970.8,-533 970.8,-533 1121.4,-533 1121.4,-533 1127.4,-533 1133.4,-539 1133.4,-545 1133.4,-545 1133.4,-584.6 1133.4,-584.6 1133.4,-590.6 1127.4,-596.6 1121.4,-596.6\"/>\n",
       "<text text-anchor=\"start\" x=\"969.6\" y=\"-573.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_CA</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-545.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.unique_users&#45;&gt;daily_unique_users_CA -->\n",
       "<g id=\"edge18\" class=\"edge\">\n",
       "<title>daily_unique_users_CA.unique_users&#45;&gt;daily_unique_users_CA</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M907.41,-564.8C920.84,-564.8 934.3,-564.8 947.27,-564.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"947.01,-568.3 957.01,-564.8 947.01,-561.3 947.01,-568.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.grain -->\n",
       "<g id=\"node14\" class=\"node\">\n",
       "<title>weekly_unique_users_CA.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M536.83,-309.6C536.83,-309.6 335.23,-309.6 335.23,-309.6 329.23,-309.6 323.23,-303.6 323.23,-297.6 323.23,-297.6 323.23,-258 323.23,-258 323.23,-252 329.23,-246 335.23,-246 335.23,-246 536.83,-246 536.83,-246 542.83,-246 548.83,-252 548.83,-258 548.83,-258 548.83,-297.6 548.83,-297.6 548.83,-303.6 542.83,-309.6 536.83,-309.6\"/>\n",
       "<text text-anchor=\"start\" x=\"334.03\" y=\"-286.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_CA.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-258.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.unique_users -->\n",
       "<g id=\"node28\" class=\"node\">\n",
       "<title>weekly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M902.42,-247.6C902.42,-247.6 646.08,-247.6 646.08,-247.6 640.08,-247.6 634.08,-241.6 634.08,-235.6 634.08,-235.6 634.08,-196 634.08,-196 634.08,-190 640.08,-184 646.08,-184 646.08,-184 902.42,-184 902.42,-184 908.42,-184 914.42,-190 914.42,-196 914.42,-196 914.42,-235.6 914.42,-235.6 914.42,-241.6 908.42,-247.6 902.42,-247.6\"/>\n",
       "<text text-anchor=\"start\" x=\"644.88\" y=\"-224.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_CA.unique_users</text>\n",
       "<text text-anchor=\"start\" x=\"755.12\" y=\"-196.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.grain&#45;&gt;weekly_unique_users_CA.unique_users -->\n",
       "<g id=\"edge25\" class=\"edge\">\n",
       "<title>weekly_unique_users_CA.grain&#45;&gt;weekly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M548.98,-257.15C572.51,-252.82 597.69,-248.17 622.37,-243.62\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"622.98,-247.07 632.18,-241.81 621.71,-240.19 622.98,-247.07\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.grain -->\n",
       "<g id=\"node15\" class=\"node\">\n",
       "<title>monthly_unique_users_US.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M540.58,-145.6C540.58,-145.6 331.48,-145.6 331.48,-145.6 325.48,-145.6 319.48,-139.6 319.48,-133.6 319.48,-133.6 319.48,-94 319.48,-94 319.48,-88 325.48,-82 331.48,-82 331.48,-82 540.58,-82 540.58,-82 546.58,-82 552.58,-88 552.58,-94 552.58,-94 552.58,-133.6 552.58,-133.6 552.58,-139.6 546.58,-145.6 540.58,-145.6\"/>\n",
       "<text text-anchor=\"start\" x=\"330.28\" y=\"-122.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_US.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-94.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.grain&#45;&gt;monthly_unique_users_US.unique_users -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>monthly_unique_users_US.grain&#45;&gt;monthly_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M552.73,-106.57C574.02,-105.24 596.56,-103.84 618.77,-102.45\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"618.72,-105.96 628.48,-101.84 618.28,-98.97 618.72,-105.96\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.filtered_interactions&#45;&gt;daily_unique_users_CA.unique_users -->\n",
       "<g id=\"edge9\" class=\"edge\">\n",
       "<title>daily_unique_users_CA.filtered_interactions&#45;&gt;daily_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M589.89,-587.16C603.17,-585.54 616.58,-583.9 629.78,-582.29\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"629.81,-585.82 639.31,-581.13 628.96,-578.87 629.81,-585.82\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.grain -->\n",
       "<g id=\"node17\" class=\"node\">\n",
       "<title>daily_unique_users_CA.grain</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M529.7,-555.6C529.7,-555.6 342.35,-555.6 342.35,-555.6 336.35,-555.6 330.35,-549.6 330.35,-543.6 330.35,-543.6 330.35,-504 330.35,-504 330.35,-498 336.35,-492 342.35,-492 342.35,-492 529.7,-492 529.7,-492 535.7,-492 541.7,-498 541.7,-504 541.7,-504 541.7,-543.6 541.7,-543.6 541.7,-549.6 535.7,-555.6 529.7,-555.6\"/>\n",
       "<text text-anchor=\"start\" x=\"341.15\" y=\"-532.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_CA.grain</text>\n",
       "<text text-anchor=\"start\" x=\"428.53\" y=\"-504.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.grain&#45;&gt;daily_unique_users_CA.unique_users -->\n",
       "<g id=\"edge10\" class=\"edge\">\n",
       "<title>daily_unique_users_CA.grain&#45;&gt;daily_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M542.03,-536.6C569.79,-539.99 600.24,-543.7 629.67,-547.29\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"629.03,-550.74 639.38,-548.48 629.88,-543.79 629.03,-550.74\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.region -->\n",
       "<g id=\"node18\" class=\"node\">\n",
       "<title>monthly_unique_users_CA.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M230.1,-801.6C230.1,-801.6 12,-801.6 12,-801.6 6,-801.6 0,-795.6 0,-789.6 0,-789.6 0,-750 0,-750 0,-744 6,-738 12,-738 12,-738 230.1,-738 230.1,-738 236.1,-738 242.1,-744 242.1,-750 242.1,-750 242.1,-789.6 242.1,-789.6 242.1,-795.6 236.1,-801.6 230.1,-801.6\"/>\n",
       "<text text-anchor=\"start\" x=\"10.8\" y=\"-778.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_CA.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-750.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.region&#45;&gt;monthly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>monthly_unique_users_CA.region&#45;&gt;monthly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M242.16,-769.8C247.88,-769.8 253.68,-769.8 259.51,-769.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"259.24,-773.3 269.24,-769.8 259.24,-766.3 259.24,-773.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.unique_users&#45;&gt;weekly_unique_users_US -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>weekly_unique_users_US.unique_users&#45;&gt;weekly_unique_users_US</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M914.52,-400.8C923.21,-400.8 931.86,-400.8 940.35,-400.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"940.3,-404.3 950.3,-400.8 940.3,-397.3 940.3,-404.3\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA -->\n",
       "<g id=\"node25\" class=\"node\">\n",
       "<title>monthly_unique_users_CA</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M1132.65,-760.6C1132.65,-760.6 959.55,-760.6 959.55,-760.6 953.55,-760.6 947.55,-754.6 947.55,-748.6 947.55,-748.6 947.55,-709 947.55,-709 947.55,-703 953.55,-697 959.55,-697 959.55,-697 1132.65,-697 1132.65,-697 1138.65,-697 1144.65,-703 1144.65,-709 1144.65,-709 1144.65,-748.6 1144.65,-748.6 1144.65,-754.6 1138.65,-760.6 1132.65,-760.6\"/>\n",
       "<text text-anchor=\"start\" x=\"958.35\" y=\"-737.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">monthly_unique_users_CA</text>\n",
       "<text text-anchor=\"start\" x=\"1026.98\" y=\"-709.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">Series</text>\n",
       "</g>\n",
       "<!-- monthly_unique_users_CA.unique_users&#45;&gt;monthly_unique_users_CA -->\n",
       "<g id=\"edge21\" class=\"edge\">\n",
       "<title>monthly_unique_users_CA.unique_users&#45;&gt;monthly_unique_users_CA</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M918.87,-728.8C924.55,-728.8 930.2,-728.8 935.8,-728.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"935.68,-732.3 945.68,-728.8 935.68,-725.3 935.68,-732.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.region -->\n",
       "<g id=\"node22\" class=\"node\">\n",
       "<title>weekly_unique_users_US.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M225.6,-391.6C225.6,-391.6 16.5,-391.6 16.5,-391.6 10.5,-391.6 4.5,-385.6 4.5,-379.6 4.5,-379.6 4.5,-340 4.5,-340 4.5,-334 10.5,-328 16.5,-328 16.5,-328 225.6,-328 225.6,-328 231.6,-328 237.6,-334 237.6,-340 237.6,-340 237.6,-379.6 237.6,-379.6 237.6,-385.6 231.6,-391.6 225.6,-391.6\"/>\n",
       "<text text-anchor=\"start\" x=\"15.3\" y=\"-368.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_US.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-340.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.region&#45;&gt;weekly_unique_users_US.filtered_interactions -->\n",
       "<g id=\"edge20\" class=\"edge\">\n",
       "<title>weekly_unique_users_US.region&#45;&gt;weekly_unique_users_US.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M237.7,-359.8C246.33,-359.8 255.14,-359.8 264.02,-359.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"263.77,-363.3 273.77,-359.8 263.77,-356.3 263.77,-363.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.region -->\n",
       "<g id=\"node23\" class=\"node\">\n",
       "<title>weekly_unique_users_CA.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M225.98,-227.6C225.98,-227.6 16.13,-227.6 16.13,-227.6 10.13,-227.6 4.13,-221.6 4.13,-215.6 4.13,-215.6 4.13,-176 4.13,-176 4.13,-170 10.13,-164 16.13,-164 16.13,-164 225.98,-164 225.98,-164 231.98,-164 237.98,-170 237.98,-176 237.98,-176 237.98,-215.6 237.98,-215.6 237.98,-221.6 231.98,-227.6 225.98,-227.6\"/>\n",
       "<text text-anchor=\"start\" x=\"14.93\" y=\"-204.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">weekly_unique_users_CA.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-176.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.region&#45;&gt;weekly_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge23\" class=\"edge\">\n",
       "<title>weekly_unique_users_CA.region&#45;&gt;weekly_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M238.15,-195.8C246.49,-195.8 255,-195.8 263.57,-195.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"263.35,-199.3 273.35,-195.8 263.35,-192.3 263.35,-199.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_US.filtered_interactions&#45;&gt;weekly_unique_users_US.unique_users -->\n",
       "<g id=\"edge14\" class=\"edge\">\n",
       "<title>weekly_unique_users_US.filtered_interactions&#45;&gt;weekly_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M596.77,-379.28C605.43,-380.34 614.12,-381.39 622.74,-382.45\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"622.19,-385.9 632.54,-383.64 623.03,-378.96 622.19,-385.9\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.filtered_interactions&#45;&gt;weekly_unique_users_CA.unique_users -->\n",
       "<g id=\"edge24\" class=\"edge\">\n",
       "<title>weekly_unique_users_CA.filtered_interactions&#45;&gt;weekly_unique_users_CA.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M597.26,-205.33C605.63,-205.83 614.03,-206.33 622.37,-206.83\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"622,-210.31 632.19,-207.41 622.42,-203.32 622,-210.31\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.region -->\n",
       "<g id=\"node27\" class=\"node\">\n",
       "<title>daily_unique_users_CA.region</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M218.85,-637.6C218.85,-637.6 23.25,-637.6 23.25,-637.6 17.25,-637.6 11.25,-631.6 11.25,-625.6 11.25,-625.6 11.25,-586 11.25,-586 11.25,-580 17.25,-574 23.25,-574 23.25,-574 218.85,-574 218.85,-574 224.85,-574 230.85,-580 230.85,-586 230.85,-586 230.85,-625.6 230.85,-625.6 230.85,-631.6 224.85,-637.6 218.85,-637.6\"/>\n",
       "<text text-anchor=\"start\" x=\"22.05\" y=\"-614.5\" font-family=\"Helvetica,sans-Serif\" font-weight=\"bold\" font-size=\"14.00\">daily_unique_users_CA.region</text>\n",
       "<text text-anchor=\"start\" x=\"113.55\" y=\"-586.5\" font-family=\"Helvetica,sans-Serif\" font-style=\"italic\" font-size=\"14.00\">str</text>\n",
       "</g>\n",
       "<!-- daily_unique_users_CA.region&#45;&gt;daily_unique_users_CA.filtered_interactions -->\n",
       "<g id=\"edge13\" class=\"edge\">\n",
       "<title>daily_unique_users_CA.region&#45;&gt;daily_unique_users_CA.filtered_interactions</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M231.07,-605.8C243.96,-605.8 257.32,-605.8 270.76,-605.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"270.54,-609.3 280.54,-605.8 270.54,-602.3 270.54,-609.3\"/>\n",
       "</g>\n",
       "<!-- weekly_unique_users_CA.unique_users&#45;&gt;weekly_unique_users_CA -->\n",
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>weekly_unique_users_CA.unique_users&#45;&gt;weekly_unique_users_CA</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M914.92,-215.8C923.31,-215.8 931.68,-215.8 939.89,-215.8\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"939.87,-219.3 949.87,-215.8 939.87,-212.3 939.87,-219.3\"/>\n",
       "</g>\n",
       "<!-- monthly_unique_users_US.filtered_interactions&#45;&gt;monthly_unique_users_US.unique_users -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>monthly_unique_users_US.filtered_interactions&#45;&gt;monthly_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M600.71,-61.5C606.86,-62.61 613.03,-63.73 619.17,-64.85\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"618.24,-68.23 628.7,-66.58 619.49,-61.35 618.24,-68.23\"/>\n",
       "</g>\n",
       "<!-- daily_unique_users_US.filtered_interactions&#45;&gt;daily_unique_users_US.unique_users -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>daily_unique_users_US.filtered_interactions&#45;&gt;daily_unique_users_US.unique_users</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M589.4,-870.38C602.9,-872.03 616.55,-873.69 629.97,-875.33\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"629.34,-878.78 639.69,-876.51 630.19,-871.83 629.34,-878.78\"/>\n",
       "</g>\n",
       "<!-- function -->\n",
       "<g id=\"node32\" class=\"node\">\n",
       "<title>function</title>\n",
       "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M143.48,-938.47C143.48,-938.47 98.63,-938.47 98.63,-938.47 92.63,-938.47 86.63,-932.47 86.63,-926.47 86.63,-926.47 86.63,-913.12 86.63,-913.12 86.63,-907.12 92.63,-901.12 98.63,-901.12 98.63,-901.12 143.48,-901.12 143.48,-901.12 149.48,-901.12 155.48,-907.12 155.48,-913.12 155.48,-913.12 155.48,-926.47 155.48,-926.47 155.48,-932.47 149.48,-938.47 143.48,-938.47\"/>\n",
       "<text text-anchor=\"middle\" x=\"121.05\" y=\"-914.38\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">function</text>\n",
       "</g>\n",
       "<!-- output -->\n",
       "<g id=\"node33\" class=\"node\">\n",
       "<title>output</title>\n",
       "<path fill=\"#ffc857\" stroke=\"black\" d=\"M138.6,-993.47C138.6,-993.47 103.5,-993.47 103.5,-993.47 97.5,-993.47 91.5,-987.47 91.5,-981.47 91.5,-981.47 91.5,-968.12 91.5,-968.12 91.5,-962.12 97.5,-956.12 103.5,-956.12 103.5,-956.12 138.6,-956.12 138.6,-956.12 144.6,-956.12 150.6,-962.12 150.6,-968.12 150.6,-968.12 150.6,-981.47 150.6,-981.47 150.6,-987.47 144.6,-993.47 138.6,-993.47\"/>\n",
       "<text text-anchor=\"middle\" x=\"121.05\" y=\"-969.38\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">output</text>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.graphs.Digraph at 0x19f4cbb9b10>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "\"\"\"A pretty simple pipeline to demonstrate function reuse.\n",
    "Note that this *also* demonstrates building a custom results builder!\n",
    "\n",
    "Why not use the standard one? Well, because time-series joining is weird.\n",
    "In this case, we're running the subdag for different granularities (daily, weekly, and monthly),\n",
    "and we want the functions that provide outputs for these granularities to yield one\n",
    "row per datapoint. This means that the weekly series will have 7x less much data as the daily\n",
    "series. Monthly series will have less than the weekly series, etc...\n",
    "\n",
    "This results builder handles it by upsampling them all to a specified granularity.\n",
    "\n",
    "Specifically, it:\n",
    "1. Up/down-samples all time-series to the granularity specified in the constructor\n",
    "2. Joins them as normal (a full outer join)\n",
    "\n",
    "Note that pandas also has capabilities for as-of joins, but those tend to be messy and tricky to work\n",
    "with. Furthermore, the as-of joins don't usually work with multiple. Upsampling/downsampling does the\n",
    "trick quite well and adds more control to the user.\n",
    "\n",
    "Note that it might be nice to pass in an argument to say which data is the \"spine\" column,\n",
    "allowing us to have a basis of data to join with. For now, however, this should be a useful piece\n",
    "of code to help with time-series joining!\n",
    "\n",
    "Furthermore, you could actually include upsampling *in* the DAG -- this has the added feature of\n",
    "encoding an index/spine column, and could be run as the final step for each subdag. Doing so is left\n",
    "as an exercise to the reader.\n",
    "\n",
    "As an example, consider the following outputs:\n",
    "1. monthly_unique_users_US\n",
    "\n",
    "timestamp\n",
    "2022-09-30    6\n",
    "Freq: M, Name: user_id, dtype: int64\n",
    "\n",
    "2. weekly_unique_users_US\n",
    "\n",
    "2022-09-04    3\n",
    "2022-09-11    3\n",
    "2022-09-18    2\n",
    "2022-09-25    4\n",
    "2022-10-02    1\n",
    "Freq: W-SUN, Name: user_id, dtype: int64\n",
    "\n",
    "3. daily_unique_users_US\n",
    "timestamp\n",
    "2022-09-01    2\n",
    "2022-09-02    1\n",
    "2022-09-03    1\n",
    "2022-09-04    0\n",
    "...\n",
    "2022-09-22    2\n",
    "2022-09-23    0\n",
    "2022-09-24    2\n",
    "2022-09-25    1\n",
    "2022-09-26    1\n",
    "Freq: D, Name: user_id, dtype: int64\n",
    "\n",
    "Joining these with upsample granularity of \"D\" would produce:\n",
    "\n",
    "            daily_unique_users_US  weekly_unique_users_US  monthly_unique_users_US\n",
    "timestamp\n",
    "2022-09-01                    2.0                     3.0                      6.0\n",
    "2022-09-02                    1.0                     3.0                      6.0\n",
    "2022-09-03                    1.0                     3.0                      6.0\n",
    "2022-09-04                    0.0                     3.0                      6.0\n",
    "2022-09-05                    0.0                     3.0                      6.0\n",
    "2022-09-06                    0.0                     3.0                      6.0\n",
    "...\n",
    "2022-09-28                    NaN                     1.0                      6.0\n",
    "2022-09-29                    NaN                     1.0                      6.0\n",
    "2022-09-30                    NaN                     1.0                      6.0\n",
    "2022-10-01                    NaN                     1.0                      NaN\n",
    "2022-10-02                    NaN                     1.0                      NaN\n",
    "\"\"\"\n",
    "\n",
    "\n",
    "class TimeSeriesJoinResultsBuilder(ResultMixin):\n",
    "    def __init__(self, upsample_frequency: str):\n",
    "        \"\"\"Initializes a results builder that does a time-series join\n",
    "        :param upsample_frequency: Argument to pandas sample() function.\n",
    "        \"\"\"\n",
    "        self.sampling_methodology = upsample_frequency\n",
    "\n",
    "    def resample(self, time_series: pd.Series):\n",
    "        return time_series.resample(\n",
    "            self.sampling_methodology\n",
    "        ).bfill()  # TODO -- think through the right fill -- ffill()/bfill()/whatnot\n",
    "\n",
    "    @staticmethod\n",
    "    def is_time_series(series: Any):\n",
    "        if not isinstance(series, pd.Series):\n",
    "            return False\n",
    "        if not series.index.inferred_type == \"datetime64\":\n",
    "            return False\n",
    "        return True\n",
    "\n",
    "    def build_result(self, **outputs: Dict[str, Any]) -> Any:\n",
    "        non_ts_output = [\n",
    "            key\n",
    "            for key, value in outputs.items()\n",
    "            if not TimeSeriesJoinResultsBuilder.is_time_series(value)\n",
    "        ]\n",
    "        if len(non_ts_output) > 0:\n",
    "            raise ValueError(\n",
    "                f\"All outputs from DAG must be time-series -- the following are not: {non_ts_output}\"\n",
    "            )\n",
    "        resampled_results = {key: self.resample(value) for key, value in outputs.items()}\n",
    "        return pd.DataFrame(resampled_results).bfill()\n",
    "\n",
    "\n",
    "\n",
    "dr = (driver.Builder()\n",
    "    .with_config({})\n",
    "    .with_modules(reusable_subdags)\n",
    "    .with_adapters(SimplePythonGraphAdapter(\n",
    "        result_builder=TimeSeriesJoinResultsBuilder(upsample_frequency=\"D\")\n",
    "    ),\n",
    ")\n",
    "\n",
    "result = dr.execute(\n",
    "    [\n",
    "        \"daily_unique_users_US\",\n",
    "        \"daily_unique_users_CA\",\n",
    "        \"weekly_unique_users_US\",\n",
    "        \"weekly_unique_users_CA\",\n",
    "        \"monthly_unique_users_US\",\n",
    "        \"monthly_unique_users_CA\",\n",
    "    ]\n",
    ")\n",
    "execution_graph = dr.visualize_execution([\n",
    "        \"daily_unique_users_US\",\n",
    "        \"daily_unique_users_CA\",\n",
    "        \"weekly_unique_users_US\",\n",
    "        \"weekly_unique_users_CA\",\n",
    "        \"monthly_unique_users_US\",\n",
    "        \"monthly_unique_users_CA\",\n",
    "    ], \"./reusable_subdags\", {\"format\": \"png\"})\n",
    "\n",
    "print(result)\n",
    "display(execution_graph)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
